% decimal vector to binary vector 
% pass examnization
function vector_out = dec_to_binary_vector(vector_in)
global digits;
integral_digits = digits * 0.6;
fractional_digits = digits * 0.4;

vector_out = [];
vector_length = length(vector_in);
for i = 1 : vector_length
    dividend = vector_in(i);
    % divide integral part and fractional part
    if dividend > 0
        integral_part = floor(dividend);
        fractional_part = dividend - integral_part;
    else
        integral_part = ceil(dividend);
        fractional_part = abs(dividend - integral_part);
    end

    integral_part_bin = [];
    % for integral part
    % whatever the integarl part is positive or negative
    % transform integral part to binary vector
    integral_part_bin = dec_to_binary(integral_part, integral_digits);
    
    % for fractional part
    fractional_part_bin  = fractional_to_binary_vector(fractional_part, fractional_digits);
    
    all_bin = [integral_part_bin, fractional_part_bin];
    vector_out = [vector_out, all_bin];
end
end

function fractional_part_bin  = fractional_to_binary_vector(fractional_part, fractional_digits)
fractional_part_bin = [];
frac_index = 1;
while fractional_part ~= 0 && frac_index <= fractional_digits
    digit = floor(fractional_part * 2);
    fractional_part = (fractional_part * 2) - digit;
    fractional_part_bin = [fractional_part_bin, digit];
    frac_index = frac_index + 1;
end
end


